package juegos.ui.views;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;

import juegos.encuentraDiferencias.PanelEncuentraDiferencias;
import juegos.memorizar.PanelMemorizar;
import juegos.practicaInstru.PanelPracticaInstru;

@SuppressWarnings("serial")
public class MainFrame extends JFrame {

	private int estadoPaneles = PANEL_PPAL;
	static int PANEL_PPAL = 0;
	static int PANEL_REGLAS = 1;
	static int PANEL_ENC_DIF = 2;
	static int PANEL_MEM = 3;
	static int PANEL_PRAC_INS = 4;

	private PanelPrincipal panelPpal = new PanelPrincipal();
	private PanelReglas panelReglas = new PanelReglas();
	private PanelEncuentraDiferencias panelEncDif = new PanelEncuentraDiferencias();
	private PanelMemorizar panelMem = new PanelMemorizar();
	private PanelPracticaInstru panelPracIns = new PanelPracticaInstru();
	private TransicionDePanel transicionPanel = new TransicionDePanel();
	private PanelFinal panelFinal = new PanelFinal();

	public MainFrame() {

		transicionPanel.addPanel(panelPpal);
		transicionPanel.addPanel(panelReglas);
		transicionPanel.addPanel(panelEncDif);
		transicionPanel.addPanel(panelMem);
		transicionPanel.addPanel(panelPracIns);
		transicionPanel.addPanel(panelFinal);
		setLayout(new BorderLayout());
		eventos();
		inicializarComponentes();
		setSize(900, 700);
		setVisible(true);
		setResizable(false);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLocationRelativeTo(null);
	}

	private void eventos() {
		panelPpal.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (e.getActionCommand().equals("PanelReglas")) {
					transicionPanel.derecha();
				}
			}
		});

		panelReglas.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (e.getActionCommand().equals("PanelEncuentraDiferencias")) {
					transicionPanel.derecha();
				}
			}
		});

		panelEncDif.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (e.getActionCommand().equals("PanelMemorizar")) {
					transicionPanel.derecha();
				}
			}
		});

		panelMem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (e.getActionCommand().equals("PanelPracticaInstru")) {
					transicionPanel.derecha();
				}
			}
		});

		panelPracIns.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (e.getActionCommand().equals("PanelFinal")) {
					transicionPanel.derecha();
				}
			}
		});

		panelFinal.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (e.getActionCommand().equals("PanelFinal")) {
					dispose();
				}
			}
		});
	}

	private void inicializarComponentes() {
		add(transicionPanel);
	}

	public static void main(String[] args) {
		new MainFrame();
	}

	public int getEstadoPaneles() {
		return estadoPaneles;
	}

	public void setEstadoPaneles(int estadoPaneles) {
		this.estadoPaneles = estadoPaneles;
	}

}
